//
//  UIFont+scaleSize.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "UIFont+scaleSize.h"

@implementation UIFont (scaleSize)
+(void)load
{
    Method imp = class_getClassMethod(self , @selector(systemFontOfSize:));
    Method changeImp = class_getClassMethod(self, @selector(TB_systemFontOfSize:));
    method_exchangeImplementations(imp, changeImp);
    
    Method immp = class_getClassMethod(self , @selector(boldSystemFontOfSize:));
    Method changeImmp = class_getClassMethod(self, @selector(TB_boldSystemFontOfSize:));
    method_exchangeImplementations(immp, changeImmp);
}
+ (UIFont *)TB_systemFontOfSize:(CGFloat)pxSize{
    //乘以多少倍
    CGFloat scale =1.00;
    if (iPhone4 || iPhone5 || iPhone6) {
        scale = KScreenWidth/375.0;
        pxSize = ceilf(scale*pxSize);
        if (iPhone5) {
            pxSize = pxSize - 1;
        }
    }
//    DLog(@"------------------         %f --------   %f",scale,pxSize);
    UIFont *font = [UIFont TB_systemFontOfSize:pxSize];
    return font;
}
//粗体`
+(UIFont*)TB_boldSystemFontOfSize:(CGFloat)pxSize
{
    //乘以多少倍
    CGFloat scale =1.00;
    if (iPhone4 || iPhone5 || iPhone6) {
        scale = KScreenHeight/812.0;
    }
    UIFont *font = [UIFont TB_boldSystemFontOfSize:pxSize*scale];
    return font;
}
@end
